<?php

namespace App\Http\Controllers\Home;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Products;
use App\ProductCategories;
use App\ShopSettings;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        // $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $productCategory = new ProductCategories();

        //全部分类
        $productCategories = $productCategory->select('product_category_id', 'name', 'level', 'pid')
                                    ->where('pid', 0)
                                    ->get()
                                    ->toArray();

        // $productCategories = $oProductCategory->categoryTree($parents);

        $limitedProducts = Products::where('limited', 1)
                            ->get()
                            ->toArray();
        return view('home.home_index',[
            'productCategories' => $productCategories, // 全部分类
            'limitedProducts' => $limitedProducts //限量款产品
        ]);
    }

    public function productDetail() 
    {
        return view('home.product_detail');
    }

}